package com.example.weather;

import android.util.Log;

import androidx.fragment.app.Fragment;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

public class BaseFragment extends Fragment implements Callback.CommonCallback<String>{

    private static final String TAG = "BaseFragment";

    public void loadData(String path){
        RequestParams params = new RequestParams(path);
        x.http().get(params,this);
    }
    //    获取数据成功时，会回调的接口
    @Override
    public void onSuccess(String result) {
        Log.i(TAG, "onSuccess: 获取数据成功");
    }
    //  获取数据失败时，会调用的接口
    @Override
    public void onError(Throwable ex, boolean isOnCallback) {
        Log.i(TAG, "onError: 获取数据失败");
    }
    //  取消请求时，会调用的接口
    @Override
    public void onCancelled(CancelledException cex) {
        Log.i(TAG, "onCancelled: 取消请求");
    }
    //  请求完成后，会回调的接口
    @Override
    public void onFinished() {

    }
}